package collections;

public class SinglyLinkedListStack<T> {
	private DoublyLinkedListNode<T> head;
	public void push(T t)
	{
		DoublyLinkedListNode<T> node = new DoublyLinkedListNode<T>(t);
		node.setNext(head);
		head = node;
	}
	
	public boolean isEmpty()
	{
		return head == null;
	}
	
	public T pop() throws RuntimeException
	{
		if(isEmpty())
			throw new RuntimeException("underflow");
		
		DoublyLinkedListNode<T> node = head;
		head = node.getNext();
		node.setNext(null);
		return node.getKey();
	}
}
